<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/WEB-INF/templates/portalTemplate.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:my="http://java.sun.com/jsf/composite/components">
	<ui:define name="content">
		<h:form>
			<rich:panel>
				<f:facet name="header">
					<h:outputText value="Lista osób bez nauczyciela" />
				</f:facet>
				
				<rich:toolbar id="menu">
					<a4j:region>
			

						<a4j:commandButton value="Dodaj nauczyciela"
							action="#{studentsWithoutTeacherBrowser.addTeacher()}" render="@form"
							disabled="#{studentsWithoutTeacherBrowser.selection==null or studentsWithoutTeacherBrowser.editMode}">
						</a4j:commandButton>

					</a4j:region>
				</rich:toolbar>
				
				
				<rich:panel id="edycjaPanel" rendered="#{studentsWithoutTeacherBrowser.editMode}">
					<a4j:region>

						<h:panelGrid columns="2">
							<h:outputText value="Imię" />
							<h:outputText value="#{studentsWithoutTeacherBrowser.user.name}" />
							<h:outputText value="Nazwisko" />
							<h:outputText value="#{studentsWithoutTeacherBrowser.user.surname}" />
							
							<h:outputText value="Data rej." />
							<h:outputText value="#{studentsWithoutTeacherBrowser.user.registrationDate}" >
								<f:convertDateTime pattern="dd.MM.yyyy"/>
							</h:outputText>
							
							
							<h:outputText value="Data ur." />
							<h:outputText value="#{studentsWithoutTeacherBrowser.user.birthDate}" >
								<f:convertDateTime pattern="dd.MM.yyyy"/>
							</h:outputText>
							
							<h:outputText value="Województow" />
							<h:outputText value="#{studentsWithoutTeacherBrowser.user.country}" />
					
							<h:outputText value="Nauczyciel" />
							<h:selectOneListbox value="#{studentsWithoutTeacherBrowser.teacherId}">
								<f:selectItems value="#{teachersDataList.selectItemsList}"/>
							</h:selectOneListbox>
							
							
						</h:panelGrid>
						
						
						
						<h:panelGrid columns="5">
							<a4j:commandButton id="submit"
								action="#{studentsWithoutTeacherBrowser.save()}" value="Zapisz"
								execute="@region" render="@form">
							</a4j:commandButton>

							<a4j:commandButton id="cancel" immediate="true"
								action="#{studentsWithoutTeacherBrowser.closeEditMode()}" render="@form"
								value="Wyjdź" />
						</h:panelGrid>
					</a4j:region>
				</rich:panel>
				
				
				
				<rich:extendedDataTable sortMode="single" value="#{studentsWithoutTeacherDataModel}" 
					selection="#{studentsWithoutTeacherBrowser.selection}"
					var="_row" rows="20" filterVar="filterValue"  >
					<a4j:ajax event="selectionchange" render="menu" immediate="true" />
					<rich:column id="col1">
						<f:facet name="header">Nazwisko</f:facet>
						<h:outputText value="#{_row.surname}" />

					</rich:column>
					<rich:column id="col2" >
						<f:facet name="header">Imię</f:facet>
						<h:outputText value="#{_row.name}" />
					</rich:column>
					<rich:column id="col3" >
						<f:facet name="header">Email</f:facet>
						<h:outputText value="#{_row.email}" />

					</rich:column>


				</rich:extendedDataTable>


			</rich:panel>

		</h:form>

	</ui:define>
</ui:composition>